package com.njxxted.activiti.modules.process.extend.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.njxxted.activiti.common.util.PageUtil;
import com.njxxted.activiti.common.util.StringUtils;
import com.njxxted.activiti.modules.process.extend.dao.ExtendActNodeBtnDao;
import com.njxxted.activiti.modules.process.extend.entity.ExtendActNodeBtnEntity;
import com.njxxted.activiti.modules.process.extend.service.ExtendActNodeBtnService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * 描述：节点按钮配置表 service
 * <p>
 * 作者：HuTongFu
 * 邮箱：hu_tongfu@163.com
 * 时间：2019-08-07 09:34:07
 */
@Service("actNodeBtnService")
public class ExtendActNodeBtnServiceImpl implements ExtendActNodeBtnService {

    @Resource
    private ExtendActNodeBtnDao extendActNodeBtnDao;

    @Override
    public ExtendActNodeBtnEntity queryObject(String id) {
        return extendActNodeBtnDao.queryObject(id);
    }

    @Override
    public PageUtil<ExtendActNodeBtnEntity> queryList(ExtendActNodeBtnEntity param) {
        if (Objects.isNull(param)) {
            return null;
        }
        PageHelper.startPage(param.getPageNum(), param.getPageSize());
        List<ExtendActNodeBtnEntity> extendActNodeBtnEntityList = extendActNodeBtnDao.queryList(param);
        PageInfo<ExtendActNodeBtnEntity> pageInfo = new PageInfo<>(extendActNodeBtnEntityList);
        return new PageUtil<>(extendActNodeBtnEntityList, (int) pageInfo.getTotal(), pageInfo.getPageSize(), pageInfo.getPageNum());

    }

    @Override
    public List<ExtendActNodeBtnEntity> queryListByBean(ExtendActNodeBtnEntity param) {
        return extendActNodeBtnDao.queryListByBean(param);
    }

    @Override
    public int save(ExtendActNodeBtnEntity extendActNodeBtnEntity) {
        extendActNodeBtnEntity.setId(StringUtils.uuidGenerator());
        return extendActNodeBtnDao.save(extendActNodeBtnEntity);
    }

    @Override
    public int update(ExtendActNodeBtnEntity extendActNodeBtnEntity) {
        return extendActNodeBtnDao.update(extendActNodeBtnEntity);
    }

    @Override
    public int delete(String id) {
        return extendActNodeBtnDao.delete(id);
    }

    @Override
    public int deleteBatch(String[] ids) {
        return extendActNodeBtnDao.deleteBatch(ids);
    }

    @Override
    public Map<String, Object> findNodeBtnMembership(String processkey, String taskDefKey, String btnId) {
        return extendActNodeBtnDao.findNodeBtnMembership(processkey, taskDefKey, btnId);
    }

}
